#include "cbuf.h"

//#define cbuf_push(PCBUF, ITEM) \
//    ({ \
//        bool ok = !cbuf_is_full(PCBUF); \
//        if (ok) { \
//            (PCBUF)->data[(PCBUF)->head] = (ITEM); \
//            (PCBUF)->head = ((PCBUF)->head + 1) % cbuf_size_(PCBUF); \
//        } \
//        ok; \
//    })



#define cbuf_take(PCBUF, PITEM) \
    ({ \
        bool ok = !cbuf_is_empty(PCBUF); \
        if (ok) { \
            *(PITEM) = (PCBUF)->data[(PCBUF)->tail]; \
            (PCBUF)->tail = ((PCBUF)->tail + 1) % cbuf_size_(PCBUF); \
        } \
        ok; \
    })

#endif
